import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** ERP 生产计划工序信息 */
export interface ProduceProcess {
    id: number; // 产品编号
    sort: number; // 执行顺序
    name: string; // 工序名称
    userId: number; // 负责人员
    type: string; // 计价方式
    price: number; // 工价
    allPrice: number; // 费用
    planFinishTime: string | Dayjs; // 计划完工时间
    remark: string; // 产品备注
}

// ERP 生产计划工序 API
export const ProduceProcessApi = {
    // 查询ERP 生产计划工序分页
    getProduceProcessPage: async (params: any) => {
        return await request.get({ url: `/erp/produce-process/page`, params })
    },

    // 查询ERP 生产计划工序详情
    getProduceProcess: async (id: number) => {
        return await request.get({ url: `/erp/produce-process/get?id=` + id })
    },

    // 新增ERP 生产计划工序
    createProduceProcess: async (data: ProduceProcess) => {
        return await request.post({ url: `/erp/produce-process/create`, data })
    },

    // 修改ERP 生产计划工序
    updateProduceProcess: async (data: ProduceProcess) => {
        return await request.put({ url: `/erp/produce-process/update`, data })
    },

    // 删除ERP 生产计划工序
    deleteProduceProcess: async (id: number) => {
        return await request.delete({ url: `/erp/produce-process/delete?id=` + id })
    },

    /** 批量删除ERP 生产计划工序 */
    deleteProduceProcessList: async (ids: number[]) => {
        return await request.delete({ url: `/erp/produce-process/delete-list?ids=${ids.join(',')}` })
    },

    // 导出ERP 生产计划工序 Excel
    exportProduceProcess: async (params) => {
        return await request.download({ url: `/erp/produce-process/export-excel`, params })
    }
}
